#!/bin/bash

APP_NAME=coupon
MODULE_PATH=.
JAR_NAME=coupon-1.0.0.jar
CFG_EXT=yml

GROUP_NAME=crm
APP_VERSION=${1:-"1.0.0"}
APP_PORT=8080

MIRROR_HOST=hub.rys.cn

MIRROR_NAME=${MIRROR_HOST}/${GROUP_NAME}/${APP_NAME}:${APP_VERSION}

docker pull ${MIRROR_HOST}/base/maven:3.6.1-alpine

docker pull ${MIRROR_HOST}/base/openjdk:8-alpine

docker build -t ${MIRROR_NAME} \
  --build-arg app_name=${APP_NAME} \
  --build-arg app_version=${APP_VERSION} \
  --build-arg app_port=${APP_PORT} \
  --build-arg module_path=${MODULE_PATH} \
  --build-arg jar_name=${JAR_NAME} \
  --build-arg cfg_ext=${CFG_EXT} \
  -f Dockerfile .

[[ $? -eq 0 ]] && docker push ${MIRROR_NAME}